import router from "./router"
import { getLocalToken } from "./utils/auth"


const whiteList = ['/login','/404']  // 移除 './login' 前面的点
// 路由守卫
router.beforeEach((to, from, next) => { 
    const token = getLocalToken()
    if(token){
        // 登录成功
        next()
    }else{ 
        if(whiteList.includes(to.path)){
            // 白名单内
            next()
        }else{ 
            next('/login')
        }
    }
})